package cn.xydpeng.springframework.beans.factory;

import cn.xydpeng.springframework.lang.Nullable;
import cn.xydpeng.springframework.util.Assert;

/**
 * @author xydpeng
 * @version v1.0
 * @date: 2022/10/20
 * @description: 工具类
 */
public abstract class BeanFactoryUtils {

    public static String transformedBeanName(String name) {
        Assert.notNull(name, "'name' must not be null");
        if (!name.startsWith(BeanFactory.FACTORY_BEAN_PREFIX)) {
            return name;
        }
        name = name.substring(BeanFactory.FACTORY_BEAN_PREFIX.length());
        return name;
    }

    /**
     * Return whether the given name is a factory dereference
     * @param name
     * @return
     */
    public static boolean isFactoryDereference(@Nullable String name) {
        return (name != null && name.startsWith(BeanFactory.FACTORY_BEAN_PREFIX));
    }

}
